home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group96a.txt / 000117_icon-group-sender _Tue May 7 06:59:08 1996.msg < prev    next >
Internet Message Format  |  1996-09-05  |  1KB

  1. Received: by cheltenham.cs.arizona.edu; Tue, 7 May 1996 12:21:39 MST
  2. Date: Tue, 7 May 1996 06:59:08 -0700
  3. From: Ralph Griswold <ralph>
  4. Message-Id: <9605071359.AA23150@ursus.cs.arizona.edu>
  5. To: H.Lawson@tees.ac.uk, icon-group@cs.arizona.edu
  6. Subject: Re:  Why are 'every', 'until', and 'while' designed to fail?
  7. Errors-To: icon-group-errors@cs.arizona.edu
  8. Status: O
  9.  
  10. The reason looping control structures fail is because they produce no
  11. value, which is equivalent to failure in Icon.
  12.  
  13. The reason there is no value is that there is no consistent way to
  14. produce one.  E.g., "do" clauses are optional.
  15.  
  16. While there are possible ways to provide an interpretation of a
  17. returned *result*, since looping control structures usually are not
  18. used in situations where their results are useful, we decided to
  19. give a simple, uniform result (failure).
  20.  
  21. Using looping control structures in ways that their results could
  22. be used generally is not good programming style -- if nothing else,
  23. it's hard to understand.
  24.  
  25. Note that you can produce a result other than failure for a control
  26. structure using break, as in
  27.  
  28.     while ... do {
  29.         ...
  30.        break s
  31.            }
  32.  
  33. which  produces s for the while-do control structure if the break
  34. expression is evaluated.
  35.  
  36.     
  37. Ralph E. Griswold            ralph@cs.arizona.edu
  38. Department of Computer Science
  39. The University of Arizona        520-621-6609 (voice)
  40. P.O. Box 210077
  41. Tucson, AZ 85721-0077            520-621-4246   (fax)
  42.